home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / i8254clock.h.z / i8254clock.h
C/C++ Source or Header  |  1992-04-03  |  5KB  |  145 lines

  1. /**************************************************************************
  2.  *                                      *
  3.  *          Copyright (C) 1988, Silicon Graphics, Inc.          *
  4.  *          Copyright (C) 1988, MIPS Computer Systems, Inc.      *
  5.  *                                      *
  6.  *  These coded instructions, statements, and computer programs  contain  *
  7.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  8.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  9.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  10.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  11.  *                                      *
  12.  **************************************************************************/
  13.  
  14. #ident    "$Revision: 3.18 $"
  15.  
  16. /*
  17.  * General time definitions
  18.  */
  19. #define    SECMIN    ((unsigned)60)            /* seconds per minute */
  20. #define    SECHOUR    ((unsigned)(60*SECMIN))        /* seconds per hour */
  21. #define    SECDAY    ((unsigned)(24*SECHOUR))    /* seconds per day */
  22. #define    SECYR    ((unsigned)(365*SECDAY))    /* sec per reg year */
  23.  
  24. #define    YRREF        1970
  25. #define    LEAPYEAR(x)    (((x) % 4) == 0)
  26. #define    TODRZERO    (1<<26)
  27. #if defined(IP6) || defined(IP12)
  28. #define BASEYEAR    0
  29. #else
  30. #define    BASEYEAR    72            /* MUST be a leap year */
  31. #endif
  32.  
  33. /*
  34.  * Definitions for 8254 programmable interval timer
  35.  *
  36.  * NOTE: counter2 is clocked at MASTER_FREQ (defined below), the
  37.  * output of counter2 is the clock for both counter0 and counter1.
  38.  * For the IP12, the counter0 output is tied to Interrupt 3 to act
  39.  * as the scheduling clock and the output of counter1 is tied to
  40.  * Interrupt 4 to act as the profiling clock.
  41.  * For the IP17, counter0 output is tied to interrupt 2 for the
  42.  * scheduling clock, and interrupt 3 for the 'fast' clock.
  43.  * For all other CPUs, counter0 output is tied to Interrupt 2 to act 
  44.  * as the scheduling clock and the output of counter1 is tied to 
  45.  * Interrupt 4 to act as the profiling clock.
  46.  */
  47. #ifndef IP12
  48.  
  49. #ifndef LANGUAGE_ASSEMBLY    /* included in some standalone assembler files */
  50. struct pt_clock {
  51.     volatile unsigned char    pt_counter0;        /* counter 0 port */
  52.     char fill0[3];
  53.     volatile unsigned char    pt_counter1;        /* counter 1 port */
  54.     char fill1[3];
  55.     volatile unsigned char    pt_counter2;        /* counter 2 port */
  56.     char fill2[3];
  57.     volatile unsigned char    pt_control;        /* control word */
  58. };
  59. #endif
  60. # define PT_COUNTER0    0        /* assembly structure offsets */
  61. # define PT_COUNTER1    4
  62. # define PT_COUNTER2    8
  63. # define PT_CONTROL    12
  64.  
  65. #else /* IP12 */
  66.  
  67. #ifdef _MIPSEB
  68. #ifndef LANGUAGE_ASSEMBLY    /* included in some standalone assembler files */
  69. struct pt_clock {
  70.     char fill0[3];
  71.     unsigned char    pt_counter0;        /* counter 0 port */
  72.     char fill1[3];
  73.     unsigned char    pt_counter1;        /* counter 1 port */
  74.     char fill2[3];
  75.     unsigned char    pt_counter2;        /* counter 2 port */
  76.     char fill3[3];
  77.     unsigned char    pt_control;        /* control word */
  78. };
  79. #else  /* LANGUAGE_ASSEMBLY */
  80. # define PT_COUNTER0    3        /* assembly structure offsets */
  81. # define PT_COUNTER1    7
  82. # define PT_COUNTER2    11
  83. # define PT_CONTROL    15
  84. #endif /* LANGUAGE_ASSEMBLY */
  85. #endif /* _MIPSEB */
  86.  
  87. #ifdef _MIPSEL
  88. #ifndef LANGUAGE_ASSEMBLY    /* included in some standalone assembler files */
  89. struct pt_clock {
  90.     unsigned char    pt_counter0;        /* counter 0 port */
  91.     char fill0[3];
  92.     unsigned char    pt_counter1;        /* counter 1 port */
  93.     char fill1[3];
  94.     unsigned char    pt_counter2;        /* counter 2 port */
  95.     char fill2[3];
  96.     unsigned char    pt_control;        /* control word */
  97.     char fill3[3];
  98. };
  99. #else  /* LANGUAGE_ASSEMBLY */
  100. # define PT_COUNTER0    0        /* assembly structure offsets */
  101. # define PT_COUNTER1    4
  102. # define PT_COUNTER2    8
  103. # define PT_CONTROL    12
  104. #endif /* LANGUAGE_ASSEMBLY */
  105. #endif /* _MIPSEL */
  106.  
  107. #endif /* IP12 */
  108.  
  109. /*
  110.  * control word definitions
  111.  */
  112. #define    PTCW_SC(x)    ((x)<<6)    /* select counter x */
  113. #define    PTCW_RBCMD    (3<<6)        /* read-back command */
  114. #define    PTCW_CLCMD    (0<<4)        /* counter latch command */
  115. #define    PTCW_LSB    (1<<4)        /* r/w least signif. byte only */
  116. #define    PTCW_MSB    (2<<4)        /* r/w most signif. byte only */
  117. #define    PTCW_16B    (3<<4)        /* r/w 16 bits, lsb then msb */
  118. #define    PTCW_MODE(x)    ((x)<<1)    /* set mode to x */
  119. #define    PTCW_BCD    0x1        /* operate in BCD mode */
  120.  
  121. /*
  122.  * Mode definitions
  123.  */
  124. #define    MODE_ITC    0        /* interrupt on terminal count */
  125. #define    MODE_HROS    1        /* hw retriggerable one-shot */
  126. #define    MODE_RG        2        /* rate generator */
  127. #define    MODE_SQW    3        /* square wave generator */
  128. #define    MODE_STS    4        /* software triggered strobe */
  129. #define    MODE_HTS    5        /* hardware triggered strobe */
  130.  
  131. #if defined(IP12)
  132. #define MASTER_FREQ    1000000        /* master frequency */
  133. #endif
  134. #if defined(IP17)
  135. #define MASTER_FREQ    10000000    /* master frequency */
  136. #endif
  137. #if !defined(MASTER_FREQ)
  138. #define    MASTER_FREQ    3686400        /* master frequency */
  139. #endif
  140.  
  141. /* 
  142.  * prom non-volatile ram conventions
  143.  */
  144. #define NVTOD_VALID    1    /* flag bit that indicates clock ok if set */
  145.